home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Mac Mania 4
/
MacMania 4.toast
/
/
Demo's
/
Igor Demo Pro
/
3 PutContentsIn Igor Pro Folder
/
Technical Notes
/
Igor Tech Notes
/
TN005 Stat x-tests
/
x-tests TEXT
< prev
Wrap
Text File
|
1990-05-09
|
3KB
|
98 lines
| Given the arrays w1 and w2, this routine returns Student's t as U_t
| and its significance as U_prob. See Numerical Recipes section 13.4 for more info.
| The data arrays are assumed to be drawn from populations with the same true variance.
|
Macro ttest(w1,w2)
string w1,w2
Prompt w1,"array 1",popup WaveList("*",";","")
Prompt w2,"array 2",popup WaveList("*",";","")
;
Silent 1
WaveStats/Q $w1
Variable ave1=V_avg, var1= V_sdev^2, n1= V_npnts
WaveStats/Q $w2
Variable ave2=V_avg, var2= V_sdev^2, n2= V_npnts
Variable df= n1+n2-2 | Degrees of freedom
Variable svar= ((n1-1)*var1+(n2-1)*var2)/df | Pooled variance
Variable/G U_t= (ave1-ave2)/sqrt(svar*(1/n1 + 1/n2))
Variable/G U_prob= betai(0.5*df,0.5,df/(df+U_t^2))
End
| Given the arrays w1 and w2, this routine returns Student's t as U_t
| and its significance as U_prob. See Numerical Recipes section 13.4 for more info.
| The data arrays are allowed to be drawn from populations with unequal variances.
|
Macro tutest(w1,w2)
string w1,w2
Prompt w1,"array 1",popup WaveList("*",";","")
Prompt w2,"array 2",popup WaveList("*",";","")
;
Silent 1
WaveStats/Q $w1
Variable ave1=V_avg, var1= V_sdev^2, n1= V_npnts
WaveStats/Q $w2
Variable ave2=V_avg, var2= V_sdev^2, n2= V_npnts
Variable/G U_t= (ave1-ave2)/sqrt(var1/n1+var2/n2)
Variable df= (var1/n1+var2/n2)^2/((var1/n1)^2/(n1-1) + (var2/n2)^2/(n2-1))^2
Variable/G U_prob= betai(0.5*df,0.5,df/(df+U_t^2))
End
| Given the PAIRED arrays w1 and w2, this routine returns Student's t as U_t
| and its significance as U_prob. See Numerical Recipes section 13.4 for more info.
|
Macro tptest(w1,w2)
string w1,w2
Prompt w1,"array 1",popup WaveList("*",";","")
Prompt w2,"array 2",popup WaveList("*",";","")
;
Silent 1
WaveStats/Q $w1
Variable ave1=V_avg, var1= V_sdev^2, n1= V_npnts
WaveStats/Q $w2
Variable ave2=V_avg, var2= V_sdev^2, n2= V_npnts
if( n1!=n2)
Abort "tptest: Data arrays must be paired."
endif
Duplicate $w1 tptest_tmp1 | Note use of wave operations to avoid macro loop
tptest_tmp1= ($w1-ave1)*($w2-ave2)
Variable df= n1-1
WaveStats/Q tptest_tmp1
Variable cov= V_avg*n1/df
KillWaves tptest_tmp1
Variable sd= sqrt((var1+var2-2*cov)/n1)
Variable/G U_t= (ave1-ave2)/sd
Variable/G U_prob= betai(0.5*df,0.5,df/(df+U_t^2))
End
| Given the arrays w1 and w2, this routine returns the value of F as U_F
| and its significance as U_prob. See Numerical Recipes section 13.4 for more info.
|
Macro Ftest(w1,w2)
string w1,w2
Prompt w1,"array 1",popup WaveList("*",";","")
Prompt w2,"array 2",popup WaveList("*",";","")
;
Silent 1
WaveStats/Q $w1
Variable ave1=V_avg, var1= V_sdev^2, n1= V_npnts
WaveStats/Q $w2
Variable ave2=V_avg, var2= V_sdev^2, n2= V_npnts
if( var1 > var2 )
Variable/G U_F= var1/var2
Variable df1= n1-1, df2= n2-1
else
Variable/G U_F= var2/var1
Variable df1= n2-1, df2= n1-1
endif
Variable/G U_prob= 2*betai(0.5*df2,0.5*df1,df2/(df2+df1*U_F))
if( U_prob > 1 )
U_prob= 2-U_prob
endif
End